<template>
  <keep-alive :include="cachedComponents">
    <RouterView></RouterView>
  </keep-alive>
</template>

<style>
*{
    margin: 0;
    padding: 0;
  }
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

</style>
<script >
export default {
  data(){
    return {
      cachedComponents: [ ]  //仅缓存当前列表中的组件
    }
  },
  mounted(){
    console.log("当前后端API地址:", process.env.VUE_APP_API_BASE_URL);
  },
  method:{
    //添加组建进入缓存
    addToCache(name){
      if(!this.cachedComponents.includes(name)){
        this.cachedComponents.push(name);
      }
    },
    //从缓存中删除组件
    removeFromCache(name){
      this.cachedComponents = this.cachedComponents.filter(c => c !== name);
    }
  }
}
</script>










<!-- 作者：宋彬-15887935394 -->
